package shmged.com.shlcm.utils;

import java.util.Comparator;

import org.json.JSONException;
import org.json.JSONObject;

public class CmJsonObjComparator implements Comparator{

	@Override
	public int compare(Object arg0, Object arg1){
		if(arg0 instanceof JSONObject&& arg1 instanceof JSONObject){
			JSONObject jsonobj0=(JSONObject)arg0;
			JSONObject jsonobj1=(JSONObject)arg1;
			try {
				if(jsonobj0.get("name")!=null && jsonobj1.get("name")!=null){
					
					String s0=(String) jsonobj0.get("name");
					String s1=(String) jsonobj1.get("name");
					return s1.compareToIgnoreCase(s0);
					
				}
			} catch (JSONException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return 0;
	}

}
